import 'package:floor/floor.dart';
import 'package:json_annotation/json_annotation.dart';

part 'group_info_db.g.dart';

/// 群组实体类
/// 用于群组基本信息的数据模型
@Entity(tableName: 'GroupList')
@JsonSerializable()
class GroupInfoDb {
  /// 创建时间
  @JsonKey(name: "created_at")
  String? createdAt;

  /// 群头像
  @JsonKey(name: "group_avatar")
  String? groupAvatar;

  /// 当前成员数
  @JsonKey(name: "group_cur_members")
  int? groupCurMembers;

  /// 群描述
  @JsonKey(name: "group_desc")
  String? groupDesc;

  /// 群ID
  @PrimaryKey()
  @JsonKey(name: "group_id")
  String? groupId;

  /// 最大成员数
  @JsonKey(name: "group_max_members")
  int? groupMaxMembers;

  /// 群名称
  @JsonKey(name: "group_name")
  String? groupName;

  /// 群公告
  @JsonKey(name: "group_notice")
  String? groupNotice;

  /// 群类型，1、普通群聊，2、企业群聊，3、临时群聊
  @JsonKey(name: "group_type")
  int? groupType;

  /// 加入验证类型 1、自由加入; 2、需要验证; 3、禁止加入
  @JsonKey(name: "join_verify_type")
  int? joinVerifyType;

  /// 群主ID
  @JsonKey(name: "group_owner_id")
  String? groupOwnerId;

  /// 是否置顶
  @JsonKey(name: "group_top", defaultValue: false)
  bool groupTop;

  /// 邀请人ID
  @JsonKey(name: "inviter_id")
  String? inviterId;

  /// 加入时间
  @JsonKey(name: "join_time", defaultValue: "")
  String joinTime;

  /// 成员昵称
  @JsonKey(name: "member_nick")
  String? memberNick;

  /// 成员角色:0、普通成员;1、管理员; 2、群主
  @JsonKey(name: "member_role", defaultValue: 0)
  int memberRole;

  /// 消息免打扰
  @JsonKey(name: "message_mute", defaultValue: false)
  bool messageMute;

  /// 禁言结束时间
  @JsonKey(name: "mute_end_time")
  String? muteEndTime;

  /// 群备注
  @JsonKey(name: "remarks")
  String? remarks;

  /// 是否显示群聊时成员昵称
  @JsonKey(name: "show_member_nick", defaultValue: true)
  bool showMemberNick;

  /// 用户头像
  @JsonKey(name: "user_avatar")
  String? userAvatar;

  /// 用户ID
  @JsonKey(name: "user_id")
  String? userId;

  /// 用户昵称
  @JsonKey(name: "user_nick")
  String? userNick;

  GroupInfoDb({
    this.createdAt,
    this.groupAvatar,
    this.groupCurMembers,
    this.groupDesc,
    this.groupId,
    this.groupMaxMembers,
    this.groupName,
    this.groupNotice,
    this.groupType,
    this.joinVerifyType,
    this.groupOwnerId,
    this.groupTop = false,
    this.inviterId,
    this.joinTime = "",
    this.memberNick,
    this.memberRole = 0,
    this.messageMute = false,
    this.muteEndTime,
    this.remarks,
    this.showMemberNick = true,
    this.userAvatar,
    this.userId,
    this.userNick,
  });

  factory GroupInfoDb.fromJson(Map<String, dynamic> json) => _$GroupInfoDbFromJson(json);

  Map<String, dynamic> toJson() => _$GroupInfoDbToJson(this);
}
